import 'package:flutter/material.dart';
import 'models/MovieItem.dart';
import 'widgets/home_movie_widget.dart';

import 'home_request.dart';

class HomeContent extends StatefulWidget {
  const HomeContent({Key? key}) : super(key: key);

  @override
  State<HomeContent> createState() => _HomeContentState();
}

class _HomeContentState extends State<HomeContent> {
  final List<MovieItem> _movies = [];

  @override
  void initState() {
    super.initState();
    HomeRequest.getMovieList(0, 10).then((value) => _movies.addAll(value));
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
        itemCount: _movies.length,
        itemBuilder: (ctx, index) {
          return HomeMovieWidget(movie: _movies[index]);
        });
  }
}
